%% validateHeartRate
%
% Validates whether heart rate values are physiologically relevant
%
%% Synatax
%
% [validationState] = validateHeartRate(heartRate);
%
% [1] = validateHeartRate(72);
%
%% Description
%
% This function attempts to verify that a specific heart rate is within a
% reasonable physiological range. We have defined this as being within 20
% and 200.
%
%% Arguments
%
%* heartRate                       - double: The heart rate value
%
%% Returns
%
%* validationState                 - double: Boolean value declaring
%                                            whether the heart rate is 
%                                            valid or not
%                                   
%% Function Side Effects
%
%* A warning message will be displayed if heartRate is not within 20
%  and 200
% 
%* A warning message will be displayed if heartRate is empty
%
%* A warning message will be displayed if heartRate is not numeric
%
%% Exceptions
%
%* N/A
%
%% See Also
% 
% getHeartRateManuallyGUI
% getFlowHeartRate
%


function [validationState] = validateHeartRate(heartRate)

physiologicalRange = 20:200;

if isempty(heartRate)
    
    validationState = 0;
    warning('validateHeartRate:heartRateEmpty', ...
            'heart rate field detected but cannot be empty');

elseif isnumeric(heartRate) == 0
    
    validationState = 0;
    warning('validateHeartRate:nonNumericHeartRate', ...
            'heart rate field detected but not numeric');

elseif isempty(find(heartRate == physiologicalRange))
    
    validationState = 0;
    warning('validateHeartRate:nonPhysiologicalHeartRate', ...
            'heart rate field detected but not between 20 and 200 bpm');
        
else 
    
    validationState = 1;
        
end


end

